<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
            list-style: none;
        }
        body{
            padding-left: 10px;
            padding-right: 10px;
            padding: 50px 0;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(90deg,#ffafbd,#ffc3a0);
            background-repeat: no-repeat;
            font-family: Yanone Kaffeesatz,sans-serif;
            box-sizing: border-box;
            color: #494a4b;
            line-height: 1.5;
        }
        .content{
            width: 400px;height: 400px;
            padding: 30px 10px 20px;
            text-align: center;
            /* width: 440px; */
            max-width: 100%;
            margin: 0 auto;
            border-radius: 15px;
            display: flex;
            flex-direction: column;
            background: #f2f2f2;
            box-sizing: border-box;
        }
        header{
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .img-wrapper{
            width: 80px;
            margin-right: 10px;
            box-sizing: border-box;
            text-align: center;
        }
        .img-wrapper>img{
            width: 100%;
            height: 100%;
            object-fit: cover;
            max-width: 100%;
            -webkit-user-drag: none;
        }
        .heading>.title{
            transform: rotate(3deg);
            font-size: 16px;
            padding: 0.25em 0.8em 0.15em;
            border-radius: 20% 5% 20% 5%/5% 20% 25% 20%;
            color: #fff;
            background: #fe7345;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            box-sizing: border-box;
            text-align: center;
            /* display: flex;
            flex-wrap: nowrap; */
        }
        .form-field{
            margin-top: 25px;
        }
        .form-field>h1{
            font-size: 16px;
            margin-bottom: 18px;
        }
        .form{
            display: flex;
            
        }
        .form>input{
            flex: 1;
        }
        .form>.submit-btn{
            /* position: relative; */
            /* display: block; */
            font-size: 16.5px;
            padding: 0.34em 0.84em;
            border: 2px solid #494a4b;
            border-radius: inherit;
            background-color: #fff;
            box-sizing: border-box;
            cursor: pointer;
            /* position: relative; */
            transform: rotate(4deg);
            border-radius: 6px;
            transition: transform .25s cubic-bezier(.175,.885,.32,1.275);
        }
        .empty-todos{
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top: 30px;
            gap: 10px;
            animation: zoom-132cabf7 .45s ease-in-out;
            display: none;
        }
        .empty-todos>span{
            font-size: 12px;
            padding-top: 5px;
            color: rgba(73,74,75,.45);
        }
        .todos{
            text-align: left;
            display: flex;
            flex-direction: column;
        }
        .todos .delete{
            display: block;
            float: right;
        }
        .todos li.active{
            background-color: #fe7345;
            color: #fff;
            text-decoration: line-through;
        }
        footer{
            flex: 1;
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
        }
        footer span{
            height: 25px;
            font-size: 10px;
        }
    </style>
</head>
<body>
    <div class="content">
        <header class="heading">
            <div class="img-wrapper">
                <img src="https://www.todolist.cn/img/note.75134fb0.svg" alt="Note">
            </div>
            <div class="title">To-Do List</div>
        </header>
        <div class="form-field">
            <h1 class="title">~ Today I need to ~</h1>
            <form action="" class="form">
                <input type="text" id="input" v-model="val" placeholder="Add new todo...">
                <button type="submit" class="submit-btn" @click.prevent="addList(val)">Submit</button>
            </form>
        </div>
        <div class="empty-todos">
            <span>Congrat, you have no more tasks to do</span>
        </div>
        <ul class="todos">
            <li v-for="(item,index) in arr" :class="{active: item.checked }" :data-id="index">
                <input type="checkbox" name="checkbox"  v-model="item.checked">
                <span>{{item.val}}</span>
                <button class="delete" @click="removeList(index)">x</button>
            </li>
        </ul>
        <footer class="options" v-show="is_show">
            <span>{{count}}item left</span>
            <span>All</span>
            <span>Active</span>
            <span>Completed</span>
            <span>Clear completed</span>
        </footer>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        new Vue({
            el : ".content",
            data : {
                val : "",
                is_show : false,
                count : [],
                arr : []
            },
            methods : {
                addList(val){
                    if(this.val){this.arr.push({"val":this.val,"checked":false});
                    this.val = ""}
                },
                removeList(index){
                    this.arr.splice(index,1)
                }
            },
            watch : {
                arr:{
                    deep : true,
                    handler(newValue){
                        this.is_show = newValue.length ? true : false;
                        this.count = newValue.filter(item=>{return item.checked===false}).length;
                    }
                }
            }
        })
    </script>
</body>




</html>